package com.liu.controller;

import com.liu.bean.User;
import com.liu.group.ISave;
import com.liu.group.IUpdate;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class UserController extends BaseController{

    @PostMapping("/user")
    public Map save(@Validated(ISave.class) @RequestBody User user, BindingResult result) {
        valid(result);
        Map map = new HashMap<>();
        map.put("code", 200);
        return map;
    }
    @PutMapping("/user")
    public Map update(@Validated(IUpdate.class) @RequestBody User user, BindingResult result) {
        valid(result);
        Map map = new HashMap<>();
        map.put("code", 200);
        return map;
    }


}
